/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import Common.Constant;
import Helper.CustomerHelper;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author KIENLT
 */
public class CustomerModel extends AbstractTableModel{
    ArrayList<CustomerHelper> CustomerList;
    
    private final String colunmsName[] = { Constant.getBundle().getString("Id"), Constant.getBundle().getString("Cusname"), Constant.getBundle().getString("Email"), Constant.getBundle().getString("Phone"), Constant.getBundle().getString("Address") };
    private final Class columnsClass[] = { String.class, String.class, String.class, String.class, String.class };
    
    public CustomerModel(ArrayList<CustomerHelper> CustomerList){
        this.CustomerList = CustomerList;
    }
    
    @Override
    public int getRowCount() {
        return CustomerList.toArray().length;
    }

    @Override
    public int getColumnCount() {
        return colunmsName.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex){
            case 0 : 
                return CustomerList.get(rowIndex).getId();
            case 1 : 
                return CustomerList.get(rowIndex).getName();
            case 2 :
                return CustomerList.get(rowIndex).getEmail();
            case 3 :
                return CustomerList.get(rowIndex).getPhone();
            case 4 :
                return CustomerList.get(rowIndex).getAddress();
            default: 
                return null;
        }
    }
    
    @Override
    public String getColumnName(int icol){
        return colunmsName[icol];
    }
    
    @Override
    public Class getColumnClass(int icol){
        return columnsClass[icol];
    }
    
}
